CFLAGS = -g
LIBS =

ENESIM_CFLAGS += $(shell pkg-config --cflags enesim)
ENESIM_LIBS += $(shell pkg-config --libs enesim)

EMAGE_CFLAGS += $(shell pkg-config --cflags emage)
EMAGE_LIBS += $(shell pkg-config --libs emage)

ENDER_CFLAGS += $(shell pkg-config --cflags ender)
ENDER_LIBS += $(shell pkg-config --libs ender)

APP_LIBS = $(ENDER_LIBS) $(EMAGE_LIBS)
APP_CFLAGS = $(ENDER_CFLAGS) $(EMAGE_CFLAGS) $(CFLAGS)

LIB_LIBS = $(ENESIM_LIBS)
LIB_CFLAGS = $(ENESIM_CFLAGS) $(CFLAGS)

BINS = tutorial01_lib tutorial01_app
all: $(BINS)



tutorial01_app_SRCS = tutorial01_app.c
tutorial01_app_OBJS = $(tutorial01_app_SRCS:.c=.o)
tutorial01_app: $(tutorial01_app_OBJS)
	$(RM) $@
	$(CC) $(APP_LIBS) $(APP_CFLAGS) $(LDFLAGS) $(tutorial01_app_OBJS) -o $@

tutorial01_lib_SRCS = tutorial01_lib.c
tutorial01_lib: $(tutorial01_lib_SRCS)
	$(RM) $@
	$(CC) $(LIB_CFLAGS) -fPIC -shared $< -o libfancy.so

.c.o:
	$(CC) $(FLAGS) $(APP_CFLAGS) -c $< -o $@

clean::
	rm -rf $(BINS) *.o *~ *.so


